package Application.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import Application.entity.Result;
import Application.entity.Student;
import Application.entity.StudentVo;
import Application.service.StudentService;
@CrossOrigin	
@RestController
@RequestMapping("/Student")
public class StudentControl {

	@Resource
	private StudentService service;
	
	@RequestMapping("/findStudentById")
	public Student findStudentById(int id) {
		return service.findStudentById(id);
	}
	
	@RequestMapping(value="/findStudentList" ,method=RequestMethod.GET)
	@ResponseBody
	public List<Student> findStudentList(){
		return service.findStudentList();
	}
	
	@RequestMapping(value="/insertStudent",method=RequestMethod.POST)
	@ResponseBody
	public Result inserStudent(Student student) {
		return service.insertStudent(student);
	}
	
	
	@PostMapping("/checklog")
	public Result checklog(Student student) {
		return service.checklog(student);
	}
	
	
	@PostMapping("/updateStudent")
	public Result updateStudent(StudentVo student) {
		System.out.println(student.getId());
		System.out.println(student.getPassword());
		System.out.println(student.getOldpassword());
		return service.update(student);
	}

	@PostMapping("/findMatesByStudentId")
	public List<Student> findMateSByStudentId(int id){
		return service.findMatesByStudentId(id);
	}
}
